package com.zhu.mapper;

import com.zhu.pojo.Inventory;
import com.zhu.pojo.Material;
import com.zhu.pojo.Person;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface InventoryMapper {
    @Select("SELECT * FROM inventory")
    public List<Inventory> materialList();
    @Select("select material_name from materials where id=#{id}")
    public String getname(Integer id);

    @Insert("INSERT INTO Materials (material_name, material_code, storage_date, ) VALUES (?, ?, NOW(), ...)")
    public void storage(Material material);

    @Update("update inventory set quantity=quantity+1,in_stock = in_stock+1 where material_id=#{id}")
    public void storageAdd(int id);

    @Select("select * from personnel ")
    public List<Person> personlist();

    @Update("update materials set  material_status='出库',dispatch_person=#{dispatch_person} where material_code=#{material_code} and device_code=#{device_code}")
    public void dispatch(Map<String,Object> map);

    @Select("select * from materials where material_name like concat('%',#{material_name},'%') and material_code like concat('%',#{material_code},'%')")
    public List<Material> query(Map<String,Object> map);
}
